<template>
  <RouterView :style="{
    '--pcmain-color': pcmainColor,
    '--pcvice-color': pcviceColor,
    '--primary': pcmainColor,
    '--el-color-primary': pcmainColor
  }" />
  <app-app-update />
  <app-error-dialog />
</template>

<script setup>
import config from '@/config'
import { getVersion } from '@/utils/getVersion'
import { getAppPackage } from '@/utils/getAppPackage'
import { getChromiums } from '@/utils/getChromiums'
import { onMounted } from 'vue'

const userStore = useUserStore()
const activeverison = ref('')
const packageJs = ref({})
const pcmainColor = ref('#3569fd')
const pcviceColor = ref('#75b5ea')


onMounted(async () => {
  activeverison.value = await getVersion()

  packageJs.value = await getAppPackage() // 获取electron中的package.json内容
  console.log(packageJs.value);
  
  userStore.savepackageJs(packageJs.value)
  document.title = `${packageJs.value.productName} V${activeverison.value}` //  设置标题为产品名称 + 版本号

  // 设置软件标题
  if (window.SDK && typeof window.SDK.receive === 'function') {
    window.SDK.receive('set-window-title', data => {
      const intervalId = setInterval(() => {
        if (document.title == data.title) {
          clearInterval(intervalId)
        } else {
          document.title = data.title
        }
      }, 1000)
    })
  }

  setTimeout(() => {
    getChromiums()
  }, 1000);
  


})
</script>

<style scoped lang="scss">
@font-face {
  font-family: 'PingFangSC';
  src: url('@/assets/font/PingFang-SC-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

*,
body {
  font-family: PingFangSC;
  color: #1d2129;
  font-size: 14px;
}

::v-deep .el-select-dropdown__item.is-selected {
  color: var(--pcmain-color) !important;
}

::v-deep .el-checkbox__input.is-checked .el-checkbox__inner {
  background-color: var(--pcmain-color);
  border-color: var(--pcmain-color);
}

::v-deep .el-checkbox__input:hover .el-checkbox__inner {
  border-color: var(--pcmain-color);
}

::v-deep .el-radio__input.is-checked .el-radio__inner {
  background-color: var(--pcmain-color);
  border-color: var(--pcmain-color);
}

::v-deep .el-checkbox__input.is-checked+.el-checkbox__label {
  color: var(--pcmain-color);
}

::v-deep .el-radio__input.is-checked+.el-radio__label {
  color: var(--pcmain-color);
}

::v-deep .el-switch.is-checked .el-switch__core {
  background-color: var(--pcmain-color);
  border-color: var(--pcmain-color);
}

::v-deep .el-select__wrapper.is-focused {
  box-shadow: 0 0 0 1px var(--pcmain-color) inset;
}
</style>


<style>
.el-select-dropdown__item.is-selected {
  color: var(--pcmain-color) !important;
}

.el-dropdown-menu__item:not(.is-disabled):hover,
.el-dropdown-menu__item:not(.is-disabled):focus {
  color: var(--pcmain-color) !important;
}

.hovepcvicecolor:hover {
  background-color: var(--pcmain-color) !important;
  border-color: var(--pcmain-color) !important;
}

.el-input .el-input__wrapper.is-focus {
  border-color: var(--pcmain-color) !important;
  box-shadow: 0 0 0 1px #3569fd inset;
}
</style>
